#include "Texture.h"

#include <ezlogger_headers.hpp>


namespace Crows3D
{
   Texture::Texture(void)
   {
      EZLOGGERSTREAM << "Texture Constructor" << std::endl;

      texture = NULL;
   }

   Texture::~Texture(void)
   {
      EZLOGGERSTREAM << "Texture Destructor" << std::endl;

      if (texture)
      {
         texture->Release();
         texture = NULL;
      }
   }

   bool Texture::Initialize(Crows3D::Device *dev, std::wstring textureFile)
   {
      EZLOGGERSTREAM << "Initializing texture from file" << std::endl;

      if (FAILED(D3DX11CreateShaderResourceViewFromFile(dev->GetDevice(), textureFile.c_str(), NULL, NULL, &texture, NULL)))
      {
         return false;
      }

      return true;
   }

   ID3D11ShaderResourceView* Texture::GetTexture()
   {
      return texture;
   }
}